package com.ruoyi.labour.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.labour.domain.LabourWantJob;
import com.ruoyi.labour.service.ILabourWantJobService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 求职信息Controller
 * 
 * @author ruoyi
 * @date 2023-06-14
 */
@RestController
@RequestMapping("/labour/job")
public class LabourWantJobController extends BaseController
{
    @Autowired
    private ILabourWantJobService labourWantJobService;

    /**
     * 查询求职信息列表
     */
    @PreAuthorize("@ss.hasPermi('labour:job:list')")
    @GetMapping("/list")
    public TableDataInfo list(LabourWantJob labourWantJob)
    {
        startPage();
        List<LabourWantJob> list = labourWantJobService.selectLabourWantJobList(labourWantJob);
        return getDataTable(list);
    }

    /**
     * 导出求职信息列表
     */
    @PreAuthorize("@ss.hasPermi('labour:job:export')")
    @Log(title = "求职信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LabourWantJob labourWantJob)
    {
        List<LabourWantJob> list = labourWantJobService.selectLabourWantJobList(labourWantJob);
        ExcelUtil<LabourWantJob> util = new ExcelUtil<LabourWantJob>(LabourWantJob.class);
        util.exportExcel(response, list, "求职信息数据");
    }

    /**
     * 获取求职信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('labour:job:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(labourWantJobService.selectLabourWantJobById(id));
    }

    /**
     * 新增求职信息
     */
    @PreAuthorize("@ss.hasPermi('labour:job:add')")
    @Log(title = "求职信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LabourWantJob labourWantJob)
    {
        return toAjax(labourWantJobService.insertLabourWantJob(labourWantJob));
    }

    /**
     * 修改求职信息
     */
    @PreAuthorize("@ss.hasPermi('labour:job:edit')")
    @Log(title = "求职信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LabourWantJob labourWantJob)
    {
        return toAjax(labourWantJobService.updateLabourWantJob(labourWantJob));
    }

    /**
     * 删除求职信息
     */
    @PreAuthorize("@ss.hasPermi('labour:job:remove')")
    @Log(title = "求职信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(labourWantJobService.deleteLabourWantJobByIds(ids));
    }
}
